package nio;

import java.nio.IntBuffer;
import java.util.*;

/**
 * description:
 * author:zt
 * date:2021-09-09
 */
public class BasicBuffer {
    public static void main(String[] args) {
        //大小为5的buffer
        IntBuffer buffer = IntBuffer.allocate(5);
        for (int i = 0; i < buffer.capacity(); i++) {
            buffer.put(i*2);
        }

        //buffer读写转换
        buffer.flip();

        while (buffer.hasRemaining()){
            System.out.println(buffer.get());
        }
    }
}
